// pages/main/distributor/updateDis/updateDis.js
import {initupdatedis,initselectOnetList} from "../../../../api/zhy/index"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    date:"",
    adminId:"",
    disList:{},
    // adminid:"",
    username:"",
    belong:"",
    address:"",
    tel:"",
  },
//修改日期
bindDateChange: function(event) {
  console.log('picker发送选择改变，携带值为', event.detail.value)
  this.setData({
    date: event.detail.value
  })
},
//根据id分销商详情
async searchdistributor(){
  let data={
    adminId:this.data.adminId
  }
  let res=await initselectOnetList(data)
  let {belong}=res.dataset
  this.setData({
    disList:res.dataset,
    belong:belong,
  })
  console.log(this.data.belong,"搜索详情列表")
},
//修改id
inputchangeid(event){
  this.setData({
    adminId:event.detail.value
  })
  console.log(this.data.adminId,"adminid")
},
//修改tel
inputchangetel(event){
  this.setData({
    tel:event.detail.value
  })
  console.log(this.data.tel,"tel")
},
//修改地址
inputchangeaddress(event){
  this.setData({
    address:event.detail.value
  })
  console.log(this.data.address,"address")
},
//修改名字
inputchangename(event){
  this.setData({
    username:event.detail.value
  })
  console.log(this.data.username,"username")
},
inputchange(){

},
async updatedetail(){
  let data={
    adminId:this.data.adminId,
    username:this.data.username,
    belong:Number(this.data.belong),
    address:this.data.address,
    tel:this.data.tel,
  }
  let res=await initupdatedis(data)
  console.log(res,"修改资料")
  if(res)
    wx.showToast({
      title: '修改成功',
      icon:"success"
  })
},
//修改资料
updatesub(){
  this.updatedetail()
},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options.adminId,"详情修改列表")
    this.setData({
      adminId:options.adminId
    })
    this.searchdistributor()
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})